package com.chery.media.library.extend

/**
 * @author MoYe_PanDeng
 * @ClassName:
 * @Description:约束扩展
 * @date: 4/7/21
 */

fun Int.constrain(min: Int = 0, max: Int = 100) = when {
    this > max -> max
    this < min -> min
    else -> this
}

fun Float.constrain(min: Float = 0f, max: Float = 100f) = when {
    this > max -> max
    this < min -> min
    else -> this
}

fun Long.constrain(min: Long = 0L, max: Long = 100L) = when {
    this > max -> max
    this < min -> min
    else -> this
}
